package com.elong.qadev.dao.impl;

import java.io.Serializable;
import java.util.ArrayList;

import org.apache.log4j.Logger;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.elong.qadev.dao.MenuDaoI;
import com.elong.qadev.entity.MenuItem;

@Repository("menuDao")
public class MenuDaoImpl implements MenuDaoI {
	Logger logger = Logger.getLogger(MenuDaoImpl.class);
	@Autowired
	private SessionFactory sessionFactory;

	@Override
	public ArrayList<MenuItem> getAllMenus() {
		@SuppressWarnings("unchecked")
		ArrayList<MenuItem> al = (ArrayList<MenuItem>) sessionFactory.getCurrentSession().createQuery("from MenuItem").list();
		logger.debug("获取菜单集合展示："+al.toString());
		return al;
	}

	@Override
	public Serializable save(MenuItem mi) {
		return sessionFactory.getCurrentSession().save(mi);
	}

}
